let storeBtn = document.getElementsByClassName("store");
for (let i = 0; i < storeBtn.length; i++) {
  let bid = document.getElementsByClassName("news")[i].getAttribute("bid");
  if (document.getElementsByClassName("store").length != 0) {
    $.ajax({
      url: "/weibo/blog/judgeBlogOfConnection",
      type: "post",
      data: {
        id: bid,
      },
      success: function (result) {
        if (result) {
          console.log("是否收藏" + result);
          let store = news[i].querySelector(".store");
          let icon = store.querySelector(".iconfont");
          let span = store.querySelector("span");

          icon.innerHTML = "&#xe663";
          icon.style.color = "#feaf2f";
          span.style.color = "#feaf2f";
          store.f = 1;
        } else {
          store.f = 0;
          icon.innerHTML = "&#xe647";
          icon.style.color = "inherit";
          span.style.color = "inherit";
        }
      },
    });
  }

  let newsCode = document.getElementsByClassName("news")[i];
  let Farther = document.getElementById("news");
  storeBtn[i].onclick = function () {
    $.ajax({
      url: "/weibo/blog/notCollecOtherBlog",
      type: "get",
      data: {
        id: bid,
      },
      success: function (result) {
        customConfirm("确定取消收藏本篇文章吗", function (result) {
          if (result) {
            Farther.removeChild(newsCode);
          }
        });
      },
      error: function (result) {
        console.log("个人页取消收藏失败");
      },
    });
  };
}
